<?php


namespace app\api\validate;


class IDMustBePositiveInt extends BaseValidate
{
    protected $rule = [
        'id' => 'require|isPositiveInteger',
        'num' => 'in:1,2,3'
    ];

    /** 是否是正整数 */
    protected function isPositiveInteger($value, $rule='', $data='', $field='')
    {
        if(preg_match("/^[1-9][0-9]*$/",$value)){
            return true;
        }else{
            return $field.'必须是正整数';
        }
    }
}